﻿namespace IBTrader.Modules.Read
{
    using IBTrader.Modules.Binarize;
    using IBTrader.Modules.Market;
    using System;
    using System.IO;

    class ReaderHistoricalData : Reader
    {
        protected override int LineSize { get { return sizeof(int) * 2 + sizeof(float) * 5; } }
        protected override IBinarizer Binarizer { get { return new BinarizerHistorical(); } }

        protected override void Do(BinaryReader reader, DateTime date, double price)
        {
            var open = reader.ReadSingle();
            var high = reader.ReadSingle();
            var low = reader.ReadSingle();
            var close = reader.ReadSingle();
            var volume = reader.ReadInt32();
            Add(TickType.Bid, date, low);
            Add(TickType.Ask, date, high);
            Add(TickType.Last, date, price);
            Add(TickType.Volume, date, volume);
        }
    }
}
